package com.museum.demo.Entity.Impl;

import com.museum.demo.Dao.CollectionEntityMapper;
import com.museum.demo.Dao.MuseumEntityMapper;
import com.museum.demo.Entity.CollectionEntity;
import com.museum.demo.Service.CollectionService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

@Service
public class CollectionEntityImpl implements CollectionService {
    private static final Logger logger = LoggerFactory.getLogger(CollectionEntityImpl.class);
    @Autowired
    private MuseumEntityMapper museumMapper;

    @Autowired
    private CollectionEntityMapper collectionEntityMapper;

    @Override
    public List<CollectionEntity> GetCollectionList() {
        return null;
    }

    @Override
    public List<CollectionEntity> SearchCollectionList(String MuseumName) {
        List<CollectionEntity> result = new ArrayList<>();

        Integer MuseumId = museumMapper.searchMuseumIdByName(MuseumName);


        if(MuseumId != null){
             result = collectionEntityMapper.GetCollectionByMuseumName(MuseumId);
        }else{
            logger.error("=======================报错！！！ ==========================博物馆名称错误/数据库中无此博物馆名称====================================================");
        }

        if(result.toString() != "[]"){
            return result;
        }
        return null;
    }
}
